/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package num7;

import java.util.ArrayList;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Usuário
 */
public class ListaAlterado extends ListaTemplate{

    public ListaAlterado(menuView view){
        listaTels(view);
    }
    
    @Override
    public void exibirListaSolicitada(ArrayList<ListaModel> li, menuView view) {
        ArrayList<ListaModel> lEdit = editarLista(li);
        view.setVisible(true);
        
        Object colunas[] = {"ID", "UF", "Nome", "Numero", "Operadora"};
        DefaultTableModel tmUsuario = new DefaultTableModel(colunas, 0) {
            @Override
            public boolean isCellEditable(int row, int col) {
                if (col == 0 || col == 1) {
                    return false;
                } else {
                    return true;
                }
            }
        };
        for (int i = 0; i < lEdit.size(); i++) {
            ListaModel l = lEdit.get(i);
            tmUsuario.addRow(new Object[]{l.getNome(), l.getId(), l.getNumero()});            
        }
        view.getTableListaAtualizada().setModel(tmUsuario);
    }

    public ArrayList<ListaModel> editarLista(ArrayList<ListaModel> li){
        ArrayList<ListaModel> lAtual = new ArrayList<>();        
        String digito = "9";
        for (int i = 0; i < li.size(); i++) {
            ListaModel listaModel = li.get(i);
            if(listaModel.getId().equalsIgnoreCase("27") || listaModel.getId().equalsIgnoreCase("28") ||
                    listaModel.getId().equalsIgnoreCase("21") || 
                    listaModel.getId().equalsIgnoreCase("22") || 
                    listaModel.getId().equalsIgnoreCase("24") || 
                    listaModel.getId().equalsIgnoreCase("11") ||
                    listaModel.getId().equalsIgnoreCase("11") ||
                    listaModel.getId().equalsIgnoreCase("12") ||
                    listaModel.getId().equalsIgnoreCase("13") ||
                    listaModel.getId().equalsIgnoreCase("14") ||
                    listaModel.getId().equalsIgnoreCase("15") ||
                    listaModel.getId().equalsIgnoreCase("16") ||
                    listaModel.getId().equalsIgnoreCase("17") ||
                    listaModel.getId().equalsIgnoreCase("18") ||
                    listaModel.getId().equalsIgnoreCase("19"))
            {
                listaModel.setNumero(digito + listaModel.getNumero());
                lAtual.add(listaModel);
            }            
    }
        return lAtual;
    
       
}
    
}
